const allRuler = [{
	type: 'phoneNum',
	ruler: /^1((34[0-8])|(8\d{2})|(([35][0-35-9]|4[579]|66|7[35678]|9[1389])\d{1}))\d{7}$/
}, {
	type: 'uname',
	ruler: /^[a-zA-Z0-9]{4,16}$/
}, {
	type: 'pwd',
	ruler: /^[a-zA-Z\d+]{6,16}$/
}, {
	type: 'newPwd',
	ruler: /^[a-zA-Z\d+]{6,16}$/
}, {
	type: 'check',
	ruler: /1/
}, {
	type: 'phonePwdCanUse',
	ruler: /1/
}, {
	type: 'school',
	ruler: /^[\u4e00-\u9fa5a-zA-Z]{3,10}$/
}, {
	type: 'roomNum',
	ruler: /^[0-9]{1,4}$/
}, {
	type: "roomtype",
	ruler: /[1|2]/
}, {
	type: "floor",
	ruler: /[1-9]|[1][0]/
}]

function checkTest(str, type) {
	let result = true;
	//console.log(str);
	for (let i = 0; i < allRuler.length; i++) {
		if (allRuler[i].type === type) {
			let reg = new RegExp(allRuler[i].ruler);
			//console.log(reg.test(str));
			if (!reg.test(str)) {

				result = false;
				break;
			}
		}

	}
	return result;
}

export default {
	checkTest
}